Top Description Fields Constructors Methods
org.eclipse.jgit.util.sha1

pack-priv Class SHA1Native

extends SHA1
Class Inheritance
Imports
java.security.MessageDigest, org.eclipse.jgit.lib.Constants, .MutableObjectId, .ObjectId

SHA1 implementation using native implementation from JDK. It doesn't support collision detection but is faster than the pure Java implementation.

Field Summary

Modifier and TypeField and Description
private final MessageDigest

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public byte[]
digest()

Implements abstract org.eclipse.jgit.util.sha1.SHA1.digest.

Finish the digest and return the resulting hash.

public void
digest(MutableObjectId
destination to copy the digest to.
id
)

Implements abstract org.eclipse.jgit.util.sha1.SHA1.digest.

Finish the digest and return the resulting hash.

public boolean
hasCollision()

Implements abstract org.eclipse.jgit.util.sha1.SHA1.hasCollision.

Check if a collision was detected.

public SHA1
reset()

Implements abstract org.eclipse.jgit.util.sha1.SHA1.reset.

Reset this instance to compute another hash.

public SHA1
setDetectCollision(boolean
a boolean.
detect
)

Implements abstract org.eclipse.jgit.util.sha1.SHA1.setDetectCollision.

Enable likely collision detection.

public ObjectId
toObjectId()

Implements abstract org.eclipse.jgit.util.sha1.SHA1.toObjectId.

Finish the digest and return the resulting hash.

public void
update(byte
a byte.
b
)

Implements abstract org.eclipse.jgit.util.sha1.SHA1.update.

Update the digest computation by adding a byte.

public void
update(byte[]
input array of bytes.
in
)

Implements abstract org.eclipse.jgit.util.sha1.SHA1.update.

Update the digest computation by adding bytes to the message.

public void
update(byte[]
input array of bytes.
in
,
int
offset to start at from in.
p
,
int
number of bytes to hash.
len
)

Implements abstract org.eclipse.jgit.util.sha1.SHA1.update.

Update the digest computation by adding bytes to the message.

Inherited from org.eclipse.jgit.util.sha1.SHA1:
newInstance

Field Detail

mdback to summary
private final MessageDigest md

Constructor Detail

SHA1Nativeback to summary
pack-priv SHA1Native()

Method Detail

digestback to summary
public byte[] digest() throws Sha1CollisionException

Implements abstract org.eclipse.jgit.util.sha1.SHA1.digest.

Doc from org.eclipse.jgit.util.sha1.SHA1.digest.

Finish the digest and return the resulting hash.

Once digest() is called, this instance should be discarded.

Returns:byte[]

the bytes for the resulting hash.

Annotations
@Override
Exceptions
Sha1CollisionException:
if a collision was detected and safeHash is false.
digestback to summary
public void digest(MutableObjectId id) throws Sha1CollisionException

Implements abstract org.eclipse.jgit.util.sha1.SHA1.digest.

Doc from org.eclipse.jgit.util.sha1.SHA1.digest.

Finish the digest and return the resulting hash.

Once digest() is called, this instance should be discarded.

Parameters
id:MutableObjectId

destination to copy the digest to.

Annotations
@Override
Exceptions
Sha1CollisionException:
if a collision was detected and safeHash is false.
hasCollisionback to summary
public boolean hasCollision()

Implements abstract org.eclipse.jgit.util.sha1.SHA1.hasCollision.

Doc from org.eclipse.jgit.util.sha1.SHA1.hasCollision.

Check if a collision was detected. This method only returns an accurate result after the digest was obtained through digest(), digest(MutableObjectId) or toObjectId(), as the hashing function must finish processing to know the final state.

Implementations not supporting collision detection always return false.

Returns:boolean

true if a likely collision was detected.

Annotations
@Override
resetback to summary
public SHA1 reset()

Implements abstract org.eclipse.jgit.util.sha1.SHA1.reset.

Doc from org.eclipse.jgit.util.sha1.SHA1.reset.

Reset this instance to compute another hash.

Returns:SHA1

this.

Annotations
@Override
setDetectCollisionback to summary
public SHA1 setDetectCollision(boolean detect)

Implements abstract org.eclipse.jgit.util.sha1.SHA1.setDetectCollision.

Doc from org.eclipse.jgit.util.sha1.SHA1.setDetectCollision.

Enable likely collision detection.

Default for implementations supporting collision detection is true.

Implementations not supporting collision detection ignore calls to this method.

Parameters
detect:boolean

a boolean.

Returns:SHA1

this

Annotations
@Override
toObjectIdback to summary
public ObjectId toObjectId() throws Sha1CollisionException

Implements abstract org.eclipse.jgit.util.sha1.SHA1.toObjectId.

Doc from org.eclipse.jgit.util.sha1.SHA1.toObjectId.

Finish the digest and return the resulting hash.

Once digest() is called, this instance should be discarded.

Returns:ObjectId

the ObjectId for the resulting hash.

Annotations
@Override
Exceptions
Sha1CollisionException:
if a collision was detected and safeHash is false.
updateback to summary
public void update(byte b)

Implements abstract org.eclipse.jgit.util.sha1.SHA1.update.

Doc from org.eclipse.jgit.util.sha1.SHA1.update.

Update the digest computation by adding a byte.

Parameters
b:byte

a byte.

Annotations
@Override
updateback to summary
public void update(byte[] in)

Implements abstract org.eclipse.jgit.util.sha1.SHA1.update.

Doc from org.eclipse.jgit.util.sha1.SHA1.update.

Update the digest computation by adding bytes to the message.

Parameters
in:byte[]

input array of bytes.

Annotations
@Override
updateback to summary
public void update(byte[] in, int p, int len)

Implements abstract org.eclipse.jgit.util.sha1.SHA1.update.

Doc from org.eclipse.jgit.util.sha1.SHA1.update.

Update the digest computation by adding bytes to the message.

Parameters
in:byte[]

input array of bytes.

p:int

offset to start at from in.

len:int

number of bytes to hash.

Annotations
@Override