Made compilable with EiffelStudio 17.05 and probably before as well.

This commit is contained in:
Jocelyn Fiat
2017-08-08 15:54:21 +02:00
parent dac50b490d
commit 818c3fb460
2 changed files with 30 additions and 5 deletions

View File

@@ -266,11 +266,10 @@ feature {NONE} -- Implementation
base64_hmacsha256 (s: READABLE_STRING_8; a_secret: READABLE_STRING_8): STRING_8 base64_hmacsha256 (s: READABLE_STRING_8; a_secret: READABLE_STRING_8): STRING_8
local local
hs256: HMAC_SHA256 ut: JWT_UTILITIES
do do
create hs256.make_ascii_key (a_secret) create ut
hs256.update_from_string (s) Result := ut.base64_hmacsha256 (s, a_secret)
Result := hs256.base64_digest --lowercase_hexadecimal_string_digest
end end
end end

View File

@@ -61,7 +61,33 @@ feature -- Encoding
do do
create hs256.make_ascii_key (a_secret) create hs256.make_ascii_key (a_secret)
hs256.update_from_string (s) hs256.update_from_string (s)
Result := hs256.base64_digest --lowercase_hexadecimal_string_digest -- if Version >= EiffelStudio 17.11 then
-- Result := hs256.base64_digest --lowercase_hexadecimal_string_digest
-- else
Result := base64_bytes_encoded_string (hs256.digest)
-- end
end
feature {NONE} -- Implementation
base64_bytes_encoded_string (a_bytes: SPECIAL [NATURAL_8]): STRING_8
-- Base64 string from `a_bytes`.
--| Note: to be removed when 17.11 is not latest release anymore.
local
s: STRING
i,n: INTEGER
do
from
i := 1
n := a_bytes.count
create s.make (n)
until
i > n
loop
s.append_code (a_bytes[i - 1])
i := i + 1
end
Result := (create {BASE64}).encoded_string (s)
end end
feature -- Decoding feature -- Decoding