core :: Bytes :: binarydigest
var b = "abcd".to_bytes
assert b.binarydigest == "01100001011000100110001101100100"
assert b.binarydigest.binarydigest_to_bytes == b
# Returns self as a stream of bits (0 and 1)
#
# ~~~
# var b = "abcd".to_bytes
# assert b.binarydigest == "01100001011000100110001101100100"
# assert b.binarydigest.binarydigest_to_bytes == b
# ~~~
fun binarydigest: String do
var elen = length * 8
var ns = new CString(elen)
var i = 0
var oi = 0
while i < length do
var c = self[i]
var b = 128
while b > 0 do
if c & b == 0 then
ns[oi] = u'0'
else
ns[oi] = u'1'
end
oi += 1
b = b >> 1
end
i += 1
end
return new FlatString.full(ns, elen, 0, elen)
end
lib/core/bytes.nit:410,2--437,4