src/main/java/org/tinyradius/packet/AccessRequest.java
private byte[] encodeChapPassword(String plaintext, byte[] chapChallenge) {
        // see RFC 2865 section 2.2
        byte chapIdentifier = (byte) SECURE_RANDOM.nextInt(256);
        byte[] chapPassword = new byte[17];
        chapPassword[0] = chapIdentifier;

        MessageDigest md5 = getMd5Digest();
        md5.reset();
        md5.update(chapIdentifier);
        md5.update(RadiusUtil.getUtf8Bytes(plaintext));
        byte[] chapHash = md5.digest(chapChallenge);

        System.arraycopy(chapHash, 0, chapPassword, 1, 16);
        return chapPassword;
    }
/**
     * Encodes a plain-text password using the given CHAP challenge.
     *
     * @param plaintext     plain-text password
     * @param chapChallenge CHAP challenge
     * @return CHAP-encoded password
     */
Encodes a plain-text password using the given CHAP challenge.

@param plaintext     plain-text password
@param chapChallenge CHAP challenge
@return CHAP-encoded password
Encodes a plain - text password using the given CHAP challenge . @param plaintext plain - text password @param chapChallenge CHAP challenge @return CHAP - encoded password
private byte[] encodeChapPassword(String plaintext, byte[] chapChallenge) {
        byte chapIdentifier = (byte) SECURE_RANDOM.nextInt(256);
        byte[] chapPassword = new byte[17];
        chapPassword[0] = chapIdentifier;
        MessageDigest md5 = getMd5Digest();
        md5.reset();
        md5.update(chapIdentifier);
        md5.update(RadiusUtil.getUtf8Bytes(plaintext));
        byte[] chapHash = md5.digest(chapChallenge);
        System.arraycopy(chapHash, 0, chapPassword, 1, 16);
        return chapPassword;
    }
private byte [ ] encodeChapPassword ( String plaintext , byte [ ] chapChallenge ) { byte chapIdentifier = ( byte ) SECURE_RANDOM . nextInt ( 256 ) ; byte [ ] chapPassword = new byte [ 17 ] ; chapPassword [ 0 ] = chapIdentifier ; MessageDigest md5 = getMd5Digest ( ) ; md5 . reset ( ) ; md5 . update ( chapIdentifier ) ; md5 . update ( RadiusUtil . getUtf8Bytes ( plaintext ) ) ; byte [ ] chapHash = md5 . digest ( chapChallenge ) ; System . arraycopy ( chapHash , 0 , chapPassword , 1 , 16 ) ; return chapPassword ; }
Encodes a plain-text password using the given CHAP challenge.
Encodes a plain - text password using the given CHAP challenge .
// see RFC 2865 section 2.2
