by_n

Function by_n 

Source
pub fn by_n(ct: &str, n: usize) -> String
Expand description

Inserts a space every n characters in a string.

This is typically used to format ciphertext into readable blocks.

§Arguments

  • ct - The input string slice.
  • n - The number of characters in each block.

§Returns

A new String with spaces inserted every n characters.

§Examples

use old_crypto_rs::helpers::by_n;

let input = "ABCDEFGHIJ";
let result = by_n(input, 5);
assert_eq!(result, "ABCDE FGHIJ");