public static long cleartextSize ( long ciphertextSize , Cryptor cryptor ) { checkArgument ( ciphertextSize >= 0 , "expected ciphertextSize to be positive, but was %s" , ciphertextSize ) ; long cleartextChunkSize = cryptor . fileContentCryptor ( ) . cleartextChunkSize ( ) ; long ciphertextChunkSize = cryptor . fileContentCryptor ( ) . ciphertextChunkSize ( ) ; long overheadPerChunk = ciphertextChunkSize - cleartextChunkSize ; long numFullChunks = ciphertextSize / ciphertextChunkSize ; // floor by int-truncation long additionalCiphertextBytes = ciphertextSize % ciphertextChunkSize ; if ( additionalCiphertextBytes > 0 && additionalCiphertextBytes <= overheadPerChunk ) { throw new IllegalArgumentException ( "Method not defined for input value " + ciphertextSize ) ; } long additionalCleartextBytes = ( additionalCiphertextBytes == 0 ) ? 0 : additionalCiphertextBytes - overheadPerChunk ; assert additionalCleartextBytes >= 0 ; return cleartextChunkSize * numFullChunks + additionalCleartextBytes ; }
Calculates the size of the cleartext resulting from the given ciphertext decrypted with the given cryptor .