Pot.js で利用可能。 PotLite.js では利用できません。
文字列 text を Arc4 で復号化します。
Arc4 アルゴリズムで暗号化された 文字列 text を復号化して返します。
現在の Pot.Arc4 インスタンス が返ります。
var arc4 = new Pot.Arc4('hoge'); // 暗号化 var cipherText = arc4.encrypt('Hello World!'); debug('cipherText = ' + cipherText); // 'cipherText = (...cipherText)' // 復号化 var origText = arc4.decrypt(cipherText); debug('origText = ' + origText); // 'origText = Hello World!'
decrypt は deferred というメソッドがあり、非同期で実行することが可能です。
非同期で実行することにより、巨大な文字列に対しても負荷を抑え実行することが可能です。
Arc4 アルゴリズムで暗号化された 文字列 text を非同期で復号化します。
暗号化された結果を引数に持つ Pot.Deferred インスタンス が返ります。
decrypt.deferred() で実行できます。
結果からは then() などによりチェインを繋げることができます。
decrypt.deferred.slow()
のようにして速度の指定ができます。
指定できる名前は以下の表を参照ください。
デフォルトの速度は normal です。
値 / メソッド名 | 速度 |
limp | 最も遅い |
doze | 遅い |
slow | 遅め |
normal | 通常 |
fast | 速め |
rapid | 速い |
ninja | 最も速い |
非同期実行の例:
var arc4 = new Pot.Arc4('hoge'); arc4.encrypt.deferred('Hello World!').then(function(cipherText) { debug('cipherText = ' + cipherText); // 'cipherText = (...cipherText)' return arc4.decrypt.deferred(cipherText).then(function(origText) { debug('origText = ' + origText); // 'origText = Hello World!' }); });