Code example for PrivateKey

Methods: getEncoded

0
            byte[] wrappedKey = cipher.wrap(priKey);
 
            cipher.init(Cipher.UNWRAP_MODE, wrapKey);
            Key key = cipher.unwrap(wrappedKey, "RSA", Cipher.PRIVATE_KEY);
 
            if (!MessageDigest.isEqual(priKey.getEncoded(), key.getEncoded()))
            { 
                return new SimpleTestResult(false, "Unwrapped key does not match"); 
            } 
 
            return new SimpleTestResult(true, getName() + ": Okay"); 
        } 
        catch (Exception e)
        { 
            return new SimpleTestResult(false, getName() + ": exception - " + e.toString(), e);
        } 
    } 
 
    public String getName()
    {