@JRubyMethod() public IRubyObject finish() { IRubyObject digest = RubyString.newStringNoCopy(getRuntime(), algo.digest()); algo.reset(); return digest; }
@JRubyMethod(required = 1) @Override public IRubyObject initialize_copy(IRubyObject obj) { if(this == obj) { return this; } ((RubyObject)obj).checkFrozen(); String name = ((DigestBase)obj).algo.getAlgorithm(); try { algo = (MessageDigest)((DigestBase)obj).algo.clone(); } catch(CloneNotSupportedException e) { throw getRuntime().newTypeError("Could not initialize copy of digest (" + name + ")"); } return this; }
public DigestBase(Ruby runtime, RubyClass type) { super(runtime,type); if(type == runtime.getModule("Digest").getClass("Base")) { throw runtime.newNotImplementedError("Digest::Base is an abstract class"); } Metadata metadata = getMetadata(type); if(metadata == null) { throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); } try { setAlgorithm(metadata); } catch(NoSuchAlgorithmException e) { throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); } }
public DigestBase(Ruby runtime, RubyClass type) { super(runtime,type); if(type == runtime.getModule("Digest").getClass("Base")) { throw runtime.newNotImplementedError("Digest::Base is an abstract class"); } Metadata metadata = getMetadata(type); if(metadata == null) { throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); } try { setAlgorithm(metadata); } catch(NoSuchAlgorithmException e) { throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); } }
@JRubyMethod(required = 1, visibility = Visibility.PRIVATE) @Override public IRubyObject initialize_copy(IRubyObject obj) { if (this == obj) return this; DigestBase from = (DigestBase) obj; from.checkFrozen(); try { this.algo = (MessageDigest) from.algo.clone(); } catch (CloneNotSupportedException e) { String name = from.algo.getAlgorithm(); throw getRuntime().newTypeError("Could not initialize copy of digest (" + name + ")"); } return this; }
@JRubyMethod(required = 1, visibility = Visibility.PRIVATE) @Override public IRubyObject initialize_copy(IRubyObject obj) { if (this == obj) return this; DigestBase from = (DigestBase) obj; from.checkFrozen(); try { this.algo = (MessageDigest) from.algo.clone(); } catch (CloneNotSupportedException e) { String name = from.algo.getAlgorithm(); throw getRuntime().newTypeError("Could not initialize copy of digest (" + name + ")"); } return this; }
@JRubyMethod(required = 1) @Override public IRubyObject initialize_copy(IRubyObject obj) { if(this == obj) { return this; } ((RubyObject)obj).checkFrozen(); String name = ((DigestBase)obj).algo.getAlgorithm(); try { algo = (MessageDigest)((DigestBase)obj).algo.clone(); } catch(CloneNotSupportedException e) { throw getRuntime().newTypeError("Could not initialize copy of digest (" + name + ")"); } return this; }
public DigestBase(Ruby runtime, RubyClass type) { super(runtime,type); if(type == runtime.getModule("Digest").getClass("Base")) { throw runtime.newNotImplementedError("Digest::Base is an abstract class"); } Metadata metadata = getMetadata(type); if(metadata == null) { throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); } try { setAlgorithm(metadata); } catch(NoSuchAlgorithmException e) { throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); } }
@JRubyMethod() public IRubyObject digest_length() { return RubyFixnum.newFixnum(getRuntime(), algo.getDigestLength()); }
public IRubyObject allocate(Ruby runtime, RubyClass klass) { return new DigestBase(runtime, klass); } };
@JRubyMethod() public IRubyObject digest_length() { return RubyFixnum.newFixnum(getRuntime(), algo.getDigestLength()); }
@JRubyMethod() public IRubyObject digest_length() { return RubyFixnum.newFixnum(getRuntime(), algo.getDigestLength()); }
public IRubyObject allocate(Ruby runtime, RubyClass klass) { return new DigestBase(runtime, klass); } };
public DigestBase(Ruby runtime, RubyClass type) { super(runtime,type); if(type == runtime.getModule("Digest").getClass("Base")) { throw runtime.newNotImplementedError("Digest::Base is an abstract class"); } Metadata metadata = getMetadata(type); if(metadata == null) { throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); } try { setAlgorithm(metadata); } catch(NoSuchAlgorithmException e) { throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); } }
private void setAlgorithm(Metadata metadata) throws NoSuchAlgorithmException { this.algo = createMessageDigest(getRuntime(), metadata.getName()); this.blockLength = metadata.getBlockLength(); } }
@JRubyMethod() public IRubyObject block_length() { if (blockLength == 0) { throw getRuntime().newRuntimeError( this.getMetaClass() + " doesn't implement block_length()"); } return RubyFixnum.newFixnum(getRuntime(), blockLength); }
@JRubyMethod() public IRubyObject block_length() { if (blockLength == 0) { throw getRuntime().newRuntimeError( this.getMetaClass() + " doesn't implement block_length()"); } return RubyFixnum.newFixnum(getRuntime(), blockLength); }
@JRubyMethod() public IRubyObject digest_length() { return RubyFixnum.newFixnum(getRuntime(), algo.getDigestLength()); }
public IRubyObject allocate(Ruby runtime, RubyClass klass) { return new DigestBase(runtime, klass); } };
@JRubyMethod() public IRubyObject block_length() { if (blockLength == 0) { throw getRuntime().newRuntimeError( this.getMetaClass() + " doesn't implement block_length()"); } return RubyFixnum.newFixnum(getRuntime(), blockLength); }