New and Improved Embedding Model for OpenAI
Note that this model is not able to write code.<p>Prompt: &quot;Write a C program to RSA encrypt a string.&quot;<p>text-embedding-ada-002:<p>%-C C  C  C  C  C  C C<p>C<p>C<p>C<p>C<p>C C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C
 C
C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C
C<p>C<p>C<p>C<p>C
C<p>C<p>C<p>C<p>C<p>C
 C
C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C<p>C  C C C  C
C C<p>C C<p>C<p>C<p>C
C
 C
C
C
C
C<p>C<p>C C C C
C
 C
C<p>C<p>C C
C
C
C
 C<p>C C
C aC C C<p>C<p>m  m m  m m  m  m  m m m
 m  m  m  m m m m  m mm  m
C mC<p>(Note: a relatively short max length)<p>Compare text-davinci-003:<p>#include &lt;stdio.h&gt; 
#include&lt;math.h&gt;<p>&#x2F;&#x2F; Utility function to find GCD of &#x27;a&#x27; 
&#x2F;&#x2F; and &#x27;b&#x27; 
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}<p>&#x2F;&#x2F; Function to find Modular Multiplicative 
&#x2F;&#x2F; Inverse of &#x27;a&#x27; under modulo &#x27;m&#x27; 
int modInverse(int a, int m) 
{ 
    a = a % m; 
    for (int x = 1; x &lt; m; x++) 
       if ((a * x) % m == 1) 
          return x; 
}<p>&#x2F;&#x2F; Function to compute a&#x2F;b under modulo m 
int modDivide(int a, int b, int m) 
{ 
    a = a % m; 
    int inv = modInverse(b, m); 
    return (inv * a) % m; 
}<p>&#x2F;&#x2F; Function to calculate (a^b)%c 
long long int power(int a, int b, int c) 
{ 
    int res = 1;
    a = a % c;
    while (b &gt; 0) 
    { 
        if (b &amp; 1) 
            res = modDivide(res * a, 1, c); 
        b = b &gt;&gt; 1; 
        a = modDivide(a * a, 1, c); 
    } 
    return res; 
}<p>&#x2F;&#x2F; C function for extended Euclidean Algorithm 
int gcdExtended(int a, int b, int <i>x, int </i>y) 
{ 
    if (a == 0) 
    { 
        <i>x = 0; 
        </i>y = 1; 
        return b; 
    } 
    int x1, y1;
    int gcd = gcdExtended(b%a, a, &amp;x1, &amp;y1); 
    <i>x = y1 - (b&#x2F;a) </i> x1; 
    <i>y = x1;<p><pre><code>    return gcd; </code></pre>
}<p>&#x2F;&#x2F; Function to generate public and private 
&#x2F;&#x2F; keys 
void generateKeys(int p, int q, int </i>e, 
                             int <i>d, int </i>n) 
{ 
    &#x2F;&#x2F; n = p<i>q 
    </i>n = p * q;<p><pre><code>    &#x2F;&#x2F; Computing phi(n) = (p-1)*(q-1) 
    int phi = (p - 1) * (q - 1); 
  
    &#x2F;&#x2F; Choose an integer e such that 
    &#x2F;&#x2F; e and phi(n) are co-prime 
    *e = 2; 
    while (*e &lt; phi) 
    { 
        if (gcd(*e, phi)==1) 
            break; 
        else
            ++*e; 
    } 
  
    &#x2F;&#x2F; Compute d such that it satisfies 
    &#x2F;&#x2F; d*e = 1 + k * phi(n) 
    int k = 2;  &#x2F;&#x2F; Fixed value 
    *d = (1 + (k * phi))&#x2F; *e; </code></pre>
}<p>&#x2F;&#x2F; Encryption Function 
long int RSA_Encrypt(int msg, int e, int n) 
{ 
    &#x2F;&#x2F; Cipher Text c = (msg ^ e) % n 
    long int c = power(msg, e, n);<p><pre><code>    return c; </code></pre>
}<p>&#x2F;&#x2F; Decryption Function 
long int RSA_Decrypt(int c, int d, int n) 
{ 
    &#x2F;&#x2F; Message msg = (c ^ d) % n 
    long int msg = power(c, d, n);<p><pre><code>    return msg; </code></pre>
}<p>&#x2F;&#x2F; Driver program 
int main() 
{ 
    &#x2F;&#x2F; Two random prime numbers 
    int p = 3; 
    int q = 7;<p><pre><code>    &#x2F;&#x2F; Message to be encrypted 
    int msg = 15; 
  
    &#x2F;&#x2F; Encryption key (e, n) 
    int e, d, n; 
  
    &#x2F;&#x2F; Calculate n and phi 
    generateKeys(p, q, &amp;e, &amp;d, &amp;n); 
  
    &#x2F;&#x2F; Encryption 
    long int c = RSA_Encrypt(msg, e, n); 
    printf(&quot;Encrypted message is: %d\n&quot;, c); 
  
    &#x2F;&#x2F; Decryption 
    long int m = RSA_Decrypt(c, d, n); 
    printf(&quot;Original Message is: %d\n&quot;, m); 
  
    return 0; 
}</code></pre>