Digest::Base

abstract class Digest::Base

Direct Known Subclasses

Defined in:

digest/base.cr

Class Method Summary

Class Method Detail

def self.base64digest(data) : StringSource

Returns the base64-encoded hash of data.

Digest::SHA1.base64digest("foo") # => "C+7Hteo/D9vJXQ3UfzxbwnXaijM="

def self.base64digest(&block) : StringSource

Returns the base64-encoded hash of data.

Digest::SHA1.base64digest do |ctx|
  ctx.update "f"
  ctx.update "oo"
end
# => "C+7Hteo/D9vJXQ3UfzxbwnXaijM="

def self.digest(data)Source

Returns the hash of data. data must respond to #to_slice.

def self.digest(&block)Source

Yields a context object with an #update(data : String | Bytes) method available. Returns the resulting digest afterwards.

digest = Digest::MD5.hexdigest do |ctx|
  ctx.update "f"
  ctx.update "oo"
end
digest.to_slice.hexstring # => "acbd18db4cc2f85cedef654fccc4a4d8"

def self.hexdigest(data) : StringSource

Returns the hexadecimal representation of the hash of data.

Digest::MD5.hexdigest("foo") # => "acbd18db4cc2f85cedef654fccc4a4d8"

def self.hexdigest(&block) : StringSource

Yields a context object with an #update(data : String | Bytes) method available. Returns the resulting digest in hexadecimal representation afterwards.

Digest::MD5.hexdigest do |ctx|
  ctx.update "f"
  ctx.update "oo"
end
# => "acbd18db4cc2f85cedef654fccc4a4d8"

© 2012–2017 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.22.0/Digest/Base.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部