@ SuppressWarnings ( "PMD.CyclomaticComplexity" ) private static byte [ ] unsalt ( final byte [ ] text ) { if ( text . length == 0 ) { throw new DecodingException ( "empty input" ) ; } final int size = text [ 0 ] ; if ( size < 0 ) { throw new DecodingException ( String . format ( "Length of salt %+d is negative, something is wrong" , size ) ) ; } if ( text . length < size + 2 ) { throw new DecodingException ( String . format ( "Not enough bytes for salt, length is %d while %d required" , text . length , size + 2 ) ) ; } byte sum = ( byte ) 0 ; for ( int idx = 0 ; idx < size ; ++ idx ) { sum += text [ idx + 1 ] ; } if ( text [ text . length - 1 ] != sum ) { throw new DecodingException ( String . format ( "Checksum %d failure, while %d expected" , text [ text . length - 1 ] , sum ) ) ; } final byte [ ] output = new byte [ text . length - size - 2 ] ; System . arraycopy ( text , size + 1 , output , 0 , output . length ) ; return output ; }
Un - salt the string .