[PR #1245] feat: Added affine cipher #1839

Closed
opened 2026-01-29 15:25:12 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/TheAlgorithms/C/pull/1245

State: closed
Merged: Yes


Description of Change

An affine cipher is a linear transformation where encryption is of the form E(x)=(ax+b) \text{ mod m } where x is the character being encrypted and m is the number of characters in the alphabet being used. Decryption is of the form D(x) = a^{-1}(x-b) \text{ mod m} where a^{-1} is the modular multiplicative inverse of a modulo m, i.e., a*a^{-1} \equiv 1 \text{ (mod m)}.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: added affine cipher

**Original Pull Request:** https://github.com/TheAlgorithms/C/pull/1245 **State:** closed **Merged:** Yes --- #### Description of Change An affine cipher is a linear transformation where encryption is of the form $E(x)=(ax+b) \text{ mod m }$ where $x$ is the character being encrypted and $m$ is the number of characters in the alphabet being used. Decryption is of the form $D(x) = a^{-1}(x-b) \text{ mod m}$ where $a^{-1}$ is the modular multiplicative inverse of $a$ modulo $m$, i.e., $a*a^{-1} \equiv 1 \text{ (mod m)}$. <!-- Thank you for your Pull Request. Please provide a description above and review the requirements below. Contributors guide: https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md --> #### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [x] Added description of change - [x] Added file name matches [File name guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#File-Name-guidelines) - [x] Added tests and example, test must pass - [x] Relevant documentation/comments is changed or added - [x] PR title follows semantic [commit guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#Commit-Guidelines) - [x] Search previous suggestions before making a new one, as yours may be a duplicate. - [x] I acknowledge that all my contributions will be made under the project's license. Notes: <!-- Please add a one-line description for developers or pull request viewers --> added affine cipher
claunia added the pull-request label 2026-01-29 15:25:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#1839