nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
44e99da
)
lib/core: Added new `hexdigest` service on `Text`
author
Lucas Bajolet
<r4pass@hotmail.com>
Tue, 20 Oct 2015 15:37:47 +0000
(11:37 -0400)
committer
Lucas Bajolet
<r4pass@hotmail.com>
Tue, 20 Oct 2015 15:39:05 +0000
(11:39 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
lib/core/bytes.nit
patch
|
blob
|
history
diff --git
a/lib/core/bytes.nit
b/lib/core/bytes.nit
index
227759a
..
94d3d27
100644
(file)
--- a/
lib/core/bytes.nit
+++ b/
lib/core/bytes.nit
@@
-289,6
+289,20
@@
redef class Text
end
return ret
end
end
return ret
end
+
+ # Gets the hexdigest of the bytes of `self`
+ #
+ # assert "<STRING/&rt;".hexdigest == "266C743B535452494E47262334373B2672743B"
+ fun hexdigest: String do
+ var ln = bytelen
+ var outns = new NativeString(ln * 2)
+ var oi = 0
+ for i in [0 .. ln[ do
+ bytes[i].add_digest_at(outns, oi)
+ oi += 2
+ end
+ return new FlatString.with_infos(outns, ln * 2, 0, ln * 2 - 1)
+ end
end
redef class FlatText
end
redef class FlatText