[njs] Added base64url encoding for crypto hash and HMAC digests.
Dmitry Volyntsev
xeioex at nginx.com
Mon Apr 2 14:13:04 UTC 2018
details: http://hg.nginx.org/njs/rev/4af5bd887b3f
branches:
changeset: 480:4af5bd887b3f
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Mon Apr 02 17:12:52 2018 +0300
description:
Added base64url encoding for crypto hash and HMAC digests.
diffstat:
njs/njs_crypto.c | 5 +++++
njs/test/njs_unit_test.c | 8 ++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diffs (40 lines):
diff -r 75d291c00c1f -r 4af5bd887b3f njs/njs_crypto.c
--- a/njs/njs_crypto.c Mon Apr 02 14:12:00 2018 +0300
+++ b/njs/njs_crypto.c Mon Apr 02 17:12:52 2018 +0300
@@ -127,6 +127,11 @@ static njs_crypto_enc_t njs_encodings[]
},
{
+ nxt_string("base64url"),
+ njs_string_base64url
+ },
+
+ {
nxt_null_string,
NULL
}
diff -r 75d291c00c1f -r 4af5bd887b3f njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Mon Apr 02 14:12:00 2018 +0300
+++ b/njs/test/njs_unit_test.c Mon Apr 02 17:12:52 2018 +0300
@@ -9088,6 +9088,10 @@ static njs_unit_test_t njs_test[] =
nxt_string("BtlFlCqiamG+GMPiK/GbvKjdK10=") },
{ nxt_string("var h = require('crypto').createHash('sha1');"
+ "h.update('AB').digest('base64url')"),
+ nxt_string("BtlFlCqiamG-GMPiK_GbvKjdK10") },
+
+ { nxt_string("var h = require('crypto').createHash('sha1');"
"h.update('AB').digest().toString('base64')"),
nxt_string("BtlFlCqiamG+GMPiK/GbvKjdK10=") },
@@ -9166,6 +9170,10 @@ static njs_unit_test_t njs_test[] =
nxt_string("rcYOA0WcS6589OttlzAAPpSQsi8=") },
{ nxt_string("var h = require('crypto').createHmac('sha1', 'secret key');"
+ "h.update('AB').digest('base64url')"),
+ nxt_string("rcYOA0WcS6589OttlzAAPpSQsi8") },
+
+ { nxt_string("var h = require('crypto').createHmac('sha1', 'secret key');"
"h.update('AB').digest().toString('base64')"),
nxt_string("rcYOA0WcS6589OttlzAAPpSQsi8=") },
More information about the nginx-devel
mailing list