Closed3
pure javascript RSA
// The passphrase used to repeatably generate this RSA key.
var PassPhrase = "The Moon is a Harsh Mistress.";
// The length of the RSA key, in bits.
var Bits = 1024;
var MattsRSAkey = cryptico.generateRSAKey(PassPhrase, Bits);
var MattsPublicKeyString = cryptico.publicKeyString(MattsRSAkey);
var PlainText = "Matt, I need you to help me with my Starcraft strategy.";
var EncryptionResult = cryptico.encrypt(PlainText, MattsPublicKeyString);
var DecryptionResult = cryptico.decrypt(EncryptionResult.cipher, MattsRSAkey);
my.generateRSAKey = function(passphrase, bitlength)
{
Math.seedrandom(sha256.hex(passphrase));
var rsa = new RSAKey();
rsa.generate(bitlength, "03");
return rsa;
}
my.publicKeyString = function(rsakey)
{
pubkey = my.b16to64(rsakey.n.toString(16));
return pubkey;
}
これ使えばいいや
このスクラップは2021/01/11にクローズされました