You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi TonyG
In my php I'm using sodium_bin2hex(sodium_crypto_box_publickey(sodium_crypto_box_keypair())) which I pass to the javascript:
bpkeypair='';
nacl_factory.instantiate(function(nacl){
akeypair=nacl.crypto_box_keypair();
message=nacl.encode_utf8(msg);
nonce=nacl.crypto_box_random_nonce();
});
nacl_factory.instantiate(function(acl){
ctext=acl.crypto_box(message,nonce,bpkeypair,akeypair.boxSk);
n2h=acl.to_hex(nonce);
});
when I pass "cipher text" and the "nonce to hex" back to php through ajax and try to decrypt the message using:
$jsnonce=sodium_hex2bin($n2h);
$keydc=$keysk.$pk;
$text=sodium_crypto_box_open($ctext,$jsnonce,$keydc);
I get this error:
Uncaught SodiumException: keypair size should be SODIUM_CRYPTO_BOX_KEYPAIRBYTES.
I'll attach the two files Im using to play around. Please help?
Thanks very much
... it looks like you're passing the public key to crypto_box_open? You probably need to supply the recipient's secret key (and the sender's public key).
@RicardoSette, thanks for supplying your example code!
Hi TonyG
In my php I'm using sodium_bin2hex(sodium_crypto_box_publickey(sodium_crypto_box_keypair())) which I pass to the javascript:
bpkeypair='';
nacl_factory.instantiate(function(nacl){
akeypair=nacl.crypto_box_keypair();
message=nacl.encode_utf8(msg);
nonce=nacl.crypto_box_random_nonce();
});
nacl_factory.instantiate(function(acl){
ctext=acl.crypto_box(message,nonce,bpkeypair,akeypair.boxSk);
n2h=acl.to_hex(nonce);
});
when I pass "cipher text" and the "nonce to hex" back to php through ajax and try to decrypt the message using:
$jsnonce=sodium_hex2bin($n2h);
$keydc=$keysk.$pk;
$text=sodium_crypto_box_open($ctext,$jsnonce,$keydc);
I get this error:
Uncaught SodiumException: keypair size should be SODIUM_CRYPTO_BOX_KEYPAIRBYTES.
I'll attach the two files Im using to play around. Please help?
Thanks very much
test.docx
testrespoonse.docx
The text was updated successfully, but these errors were encountered: