#!/bin/bash

# Check for the correct number of arguments
if [ "$#" -ne 2 ]; then
    echo "Usage: $0 source destination"
    exit 1
fi

# Set variables for source and destination
src="$1"
dest="$2"

# Use hardware serial as decryption key
serial=$(sed 's/.*androidboot.serialno=\([^ ]*\).*/\1/' /proc/cmdline)
keyfile=$(mktemp)
echo -n "$serial" > "$keyfile"

# Decrypt the file
cat "$src" | ccrypt -d -k "$keyfile" > "$dest"
rm -f "$keyfile"
