-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from adinapoli/issue-1
Issue 1, Encryption support
- Loading branch information
Showing
9 changed files
with
403 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ dist | |
.cabal-sandbox | ||
cabal.sandbox.config | ||
shell.nix | ||
cabal.config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
module Main where | ||
|
||
import Crypto.RNCryptor.V3.Encrypt | ||
import qualified System.IO.Streams as S | ||
import System.Environment | ||
import qualified Data.ByteString.Char8 as B | ||
|
||
main :: IO () | ||
main = do | ||
args <- getArgs | ||
case args of | ||
key:_ -> encryptStream (B.pack key) S.stdin S.stdout | ||
_ -> putStrLn "usage: rncryptor-encrypt <key>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Crypto.RNCryptor.Padding | ||
( pkcs7Padding ) where | ||
|
||
import Data.ByteString (ByteString) | ||
import qualified Data.ByteString as B | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
-- | Computes the padding as per PKCS#7. The specification can be found | ||
-- here: <http://tools.ietf.org/html/rfc5652#section-6.3> | ||
pkcs7Padding :: Int | ||
-- ^ The block size (e.g. 16 bytes) | ||
-> Int | ||
-- ^ The input size | ||
-> ByteString | ||
-- ^ The resulting padding | ||
pkcs7Padding k l = | ||
let octetsSize = k - (l `rem` k) | ||
in B.pack $ replicate octetsSize (fromIntegral octetsSize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.